From: Florian Müllner Date: Sat, 16 Feb 2019 16:44:27 +0000 (+0100) Subject: ci: Sync check-commit-log script with mutter X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~888^2^2~92 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d671eb196950eb07c94e9c5f16db84fb328faf7e;p=gnome-shell.git ci: Sync check-commit-log script with mutter A couple of cleanups came out from the review in mutter, catch up with those. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/408 --- diff --git a/.gitlab-ci/check-commit-log.sh b/.gitlab-ci/check-commit-log.sh index 87f1978ce..cc3bcee60 100755 --- a/.gitlab-ci/check-commit-log.sh +++ b/.gitlab-ci/check-commit-log.sh @@ -11,9 +11,21 @@ branch_point=$(git merge-base HEAD FETCH_HEAD) commits=$(git log --format='format:%H' $branch_point..$CI_COMMIT_SHA) -test -z "$commits" && { echo Commit range empty; exit 1; } +if [ -z "$commits" ]; then + echo Commit range empty + exit 1 +fi + +function commit_message_has_url() { + commit=$1 + commit_message=$(git show -s --format='format:%b' $commit) + echo "$commit_message" | grep -qe "\($CI_MERGE_REQUEST_PROJECT_URL/\(issues\|merge_requests\)/[0-9]\+\|https://bugzilla.gnome.org/show_bug.cgi?id=[0-9]\+\)" + return $? +} for commit in $commits; do - git show -s --format='format:%b' $commit | grep -qe "\($CI_MERGE_REQUEST_PROJECT_URL/\(issues\|merge_requests\)/[0-9]\+\|https://bugzilla.gnome.org/show_bug.cgi?id=[0-9]\+\)" || - { echo "Missing merge request or issue URL on commit $(echo $commit | cut -c -8)"; exit 1; } + if ! commit_message_has_url $commit; then + echo "Missing merge request or issue URL on commit $(echo $commit | cut -c -8)" + exit 1 + fi done